<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>收货人信息</title>
    <link rel="stylesheet" href="../../../../start/layui/css/layui.css" media="all">
    <style>
        .layui-form-select .layui-input {
            padding-right: 0px;
            cursor: pointer;
        }
    </style>
    <script src="../../../../start/layui/layui.js"></script>
</head>
<body>
<form class="layui-form"  method="post">
    <div class="layui-row" style="padding: 10px">
        <div class="layui-col-md4">
            <label class="layui-form-label">收货单位</label>
            <div class="layui-input-inline">
                <input type="text" autocomplete="off" id="forwardingunit" class="layui-input">
            </div>
        </div>
        <div class="layui-col-md4">
            <label class="layui-form-label">联系人</label>
            <div class="layui-input-inline">
                <input type="text" autocomplete="off" id="clientname" class="layui-input">
            </div>
        </div>
        <div class="layui-col-md4">
            <label class="layui-form-label">联系电话</label>
            <div class="layui-input-inline">
                <input type="text" autocomplete="off" id="phone" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-row" style="padding: 10px">
        <div class="layui-col-md8">
            <div class="layui-form-item" style="margin-bottom: 5px">
                <label class="layui-form-label">请选择地区</label>
                <div class="layui-inline">
                    <select name="province" id="province1" class="province" lay-search lay-filter="province">
                        <option value="">省份</option>
                    </select>
                </div>
                <div class="layui-inline">
                    <select name="city" id="city1"   class="city"  lay-search lay-filter="city">
                        <option value="">地级市</option>
                    </select>
                </div>
                <div class="layui-inline">
                    <select name="district" id="district1" lay-filter="district" class="district" lay-search>
                        <option value="">县/区</option>
                    </select>
                </div>
            </div>
        </div>
        <div class="layui-col-md4">
            <div class="layui-inline">
                <label class="layui-form-label"  style="padding-left: 0px;width: 95px">收货详细地址</label>
                <div class="layui-input-inline">
                    <input type="tel" name="detailedAddress1"  required id="detailedAddress1" autocomplete="on" class="layui-input" lay-verify="required">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row" style="padding: 10px">
        <div class="layui-col-md4">
            <label class="layui-form-label">客户等级</label>
            <div class="layui-input-inline">
                <input type="text" autocomplete="off" id="clientgrade" class="layui-input">
            </div>
        </div>
        <div class="layui-col-md4">
            <label class="layui-form-label">银行账户</label>
            <div class="layui-input-inline">
                <input type="text" autocomplete="off" id="bankcard" class="layui-input">
            </div>
        </div>
        <div class="layui-col-md4">
            <label class="layui-form-label">备用电话</label>
            <div class="layui-input-inline">
                <input type="text" autocomplete="off" id="alternatephone" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-row" style="padding: 10px">
        <div class="layui-col-md4">
            <div class="layui-inline">
                <label class="layui-form-label">&nbsp;</label>
                <div class="layui-input-inline">
                    <button type="button" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                </div>
            </div>
        </div>
    </div>
</form>
</body>
</html>
<script>
    layui.use(['form','jquery'], function(){
        var form = layui.form;
        var $ = layui.jquery;

        //显示网址
        var locationi=location.href;
        //根据下标截取字符串获得id
        var id=locationi.substring(locationi.indexOf("=")+1);

        if (id!=0){
            $.ajax({
                url: "../../../../XclConsignerControllerGetConsignerById",
                type: "post",
                data: {
                    id:id
                },
                dataType: "json",
                success: function (data) {
                    //收货单位
                    $("#forwardingunit").val(data.forwardingunit)
                    //联系人
                    $("#clientname").val(data.clientname)
                    //客户等级
                    $("#clientgrade").val(data.clientgrade)
                    //银行卡号
                    $("#bankcard").val(data.bankcard)
                    //备注地址
                    $("#detailedAddress1").val(data.remark)
                    //电话
                    $("#phone").val(data.phone)
                    //备用电话
                    $("#alternatephone").val(data.alternatephone)
                }
            })
        }

        //提交
        form.on('submit(demo1)', function(data){
            if (id!=0){
                $.ajax({
                    url: "../../../../XclConsignerControllerUpdateConsignerByid",
                    type: "post",
                    data: {
                        consignerId:id,
                        forwardingunit:$("#forwardingunit").val(),
                        clientname:$("#clientname").val(),
                        clientgrade:$("#clientgrade").val(),
                        bankcard:$("#bankcard").val(),
                        remark:$("#detailedAddress1").val(),
                        phone:$("#phone").val(),
                        alternatephone:$("#alternatephone").val()
                    },
                    dataType: "text",
                    success: function (data) {
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                        layer.closeAll("iframe");//关闭iframe层
                        //修改成功后刷新父界面
                        window.parent.location.reload();
                    }
                })
            } else {
                $.ajax({
                    url: "../../../../XclConsignerControllerInsertConsigner",
                    type: "post",
                    data: {
                        forwardingunit:$("#forwardingunit").val(),
                        clientname:$("#clientname").val(),
                        clientgrade:$("#clientgrade").val(),
                        bankcard:$("#bankcard").val(),
                        remark:$("#detailedAddress1").val(),
                        phone:$("#phone").val(),
                        alternatephone:$("#alternatephone").val()
                    },
                    dataType: "text",
                    success: function (data) {
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                        layer.closeAll("iframe");//关闭iframe层
                        //修改成功后刷新父界面
                        window.parent.location.reload();
                    }
                })
            }
        })
    })
</script>
<!-- 三级联动 -->
<script type="text/javascript" src="../../../../start/layui/js/area2.js"></script>
<script type="text/javascript" src="../../../../start/layui/js/xcl.js"></script>